<?php ob_start() ?>

    <!-- 主内容区 -->
    <div class="pt-16 pb-8 min-h-screen">
        <div class="container mx-auto px-4">
            <!-- 页面标题 -->
            <div class="mt-8 mb-6 flex flex-col md:flex-row md:items-center md:justify-between">
                <div>
                    <h2 class="text-[clamp(1.5rem,3vw,2.5rem)] font-bold text-gray-800">页面链接列表</h2>
                    <p class="text-gray-600 mt-1">显示所有页面链接数据</p>
                </div>
                <!-- 下载按钮 -->
                <a href="<?= base_url('page-links/export-csv') ?>" class="bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-md">下载 CSV</a>
            </div>

            <!-- 成功和错误提示 -->
            <?php if (session()->has('success')): ?>
                <div class="text-green-500 mb-4"><?= session('success') ?></div>
            <?php endif; ?>
            <?php if (session()->has('error')): ?>
                <div class="text-red-500 mb-4"><?= session('error') ?></div>
            <?php endif; ?>

            <!-- 页面链接列表 -->
            <div class="bg-white rounded-xl shadow-lg p-6">
                <table class="w-full">
                    <thead>
                        <tr>
                            <!-- 这里可以根据实际的默认字段添加更多列 -->
                            <th class="text-left pb-2">序号</th>
                            <th class="text-left pb-2">起点基地名称</th>
                            <th class="text-left pb-2">起点基地序号</th>
                            <th class="text-left pb-2">终点基地序号</th>
                            <th class="text-left pb-2">终点基地名称</th>
                            <th class="text-left pb-2">终点基地得分</th>
                            <th class="text-left pb-2">设置时间</th>
                            <!-- 可以继续添加其他默认字段 -->
                        </tr>
                    </thead>
                    <tbody>
                        <?php $index = 1; foreach ($pageLinks as $pageLink): ?>
                            <tr>
                                <td class="py-2"><?= $index++ ?></td>
                                <td class="py-2"><?= $pageLink['from_name'] ?? '' ?></td>
                                <td class="py-2"><?= $pageLink['from_order'] ?? '' ?></td>
                                <td class="py-2"><?= $pageLink['to_order'] ?? '' ?></td>
                                <td class="py-2"><?= $pageLink['to_name'] ?? '' ?></td>
                                <td class="py-2"><?= $pageLink['score'] ?? '' ?></td>
                                <td class="py-2"><?= $pageLink['update_time'] ?? '' ?></td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

<?php $content = ob_get_clean() ?>

<?= view('layouts/base', ['content' => $content]) ?>